load HLine,DrawEdges

! get labels
#useTag=#msg
#sex=""
if #msg1 is validlink
  #sex=@#msg1.SEX
else
  if #msg="HUSB"
    #sex=@this.HUSB.SEX
  else
    #sex=@this.WIFE.SEX
  endif
endif
if #sex="M"
  #useTag="HUSB"
else if #sex="F"
  #useTag="WIFE"
else if #msg="HUSB"
  #sex="M"
else
  #sex="F"
endif
if @this._UMR=""
  #label=#useTag
else
  if #useTag="HUSB"
    #label="Father"
  else
    #label="Mother"
  endif
endif

newline
! label
gosub HLine,2

newline
#husbStart=#vpos$
cell static,local(#label)&": "
set tabwidth -1 alignment right

! link to spouse or to attach a spouse
if #msg1 is validlink
  cell LinkButton
  set RecordLink #msg1 PaneID "Pedi"
  TextExpression @#msg1.rec
  AppendedExpression altview
  set font "Hyperlink Text"
  set border no alignment left width -1
  ! #label will be HUSB, WIFE, Father, or Mother
  #helpKey="Click to view "&#label&"'s record"
  help local(#helpKey)

else
  cell static
  set width -1
endif

! birth
gosub HLine,1
newline
cell static,local("Born")&": "
set tabwidth 1 alignment right

cell expression,@#msg1.BIRT.DATE
set AppendedExpression view
set width #dateWidth

cell static,local("PLAC")&": "
SizeToFit

cell expression,@#msg1.BIRT.PLAC
set width -1

! death
gosub HLine,1
newline
cell static,local("Died")&": "
set tabwidth 1 alignment right

cell expression,@#msg1.DEAT.DATE
set AppendedExpression view
set width #dateWidth

cell static,local("PLAC")&": "
SizeToFit

cell expression,@#msg1.DEAT.PLAC
set width -1

! parents
gosub HLine,1
newline
#fatherRec=@#msg1.FAMC.HUSB
if #fatherRec!=""
  if @#fatherRec.SEX="F"
    cell static,local("Mother")&": "
    #helpKey="Click to view Mother's record"
  else
    cell static,local("Father")&": "
    #helpKey="Click to view Father's record"
  endif
  set tabwidth 1 alignment right
  cell LinkButton
  set RecordLink #fatherRec PaneID "Pedi"
  TextExpression @#fatherRec.rec
  AppendedExpression altview
  set font "Hyperlink Text"
  set border no alignment left tabwidth 1
  help local(#helpKey)
else
  cell static,local("Father")&": "
  set tabwidth 1 alignment right
  cell static
  set tabwidth 1
endif

#motherRec=@#msg1.FAMC.WIFE
if #motherRec!=""
  if @#motherRec.SEX="M"
    cell static,local("Father")&": "
    #helpKey="Click to view Father's record"
  else
    cell static,local("Mother")&": "
    #helpKey="Click to view Mother's record"
  endif
  sizetofit
  set offset 1
  cell LinkButton
  set RecordLink @#motherRec PaneID "Pedi"
  TextExpression @#motherRec.rec
  AppendedExpression altview
  set font "Hyperlink Text"
  set border no alignment left width -1
  help local(#helpKey)
else
  cell static,local("Mother")&": "
  sizetofit -1
  cell static
  set width -1
endif

gosub DrawEdges,#husbStart

